package cn.com.dhcc.adam.log;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;

public class SLF4JTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Logger logger = LoggerFactory.getLogger(SLF4JTest.class);
		logger.info("Hello World");
		
		
		SLF4JTest sti = new SLF4JTest();
		sti.setTemperature(2);
		sti.setTemperature(34);
		sti.setTemperature(55);
		
		System.out.println(sti.add(1,2,3,4,6,23));
	}

	final Logger slflogger = LoggerFactory.getLogger(SLF4JTest.class);
	Integer t;
	Integer oldT;

	public void setTemperature(Integer temperature) {
		oldT = t;
		t = temperature;
		slflogger.info(" Temperature is {}.", t);
	    Marker fatal = MarkerFactory.getMarker("FATAL");
		if(slflogger.isDebugEnabled()) {
			slflogger.debug("Temperature set to {}. Old temperature was {}.", t, oldT);
		}
		if (temperature.intValue() > 50) {
			slflogger.info("Temperature has risen above 50 degrees.");
		}
		slflogger.error(fatal, "Failed to obtain JDBC connection");
	}
	/**
	 * 参数个数可变
	 * @param list
	 * @return
	 */
	public int add(int... list){
		slflogger.info("参数个数：" + list.length);
		   int sum = 0;
		   for (int item:list)
		    sum += item;
		   return sum;
		}
}
